package cn.itcast.tlias.com.tliaswork.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class MyAspct8 {


    @Pointcut("execution(* cn.itcast.tlias.com.tliaswork.service.impl.DeptServiceImpl.delete(int))")
    private void pet() {
    }


    @Before("pet()")
    public void before(JoinPoint joinPoint) {
        log.info("MyAspct8 before..............");
    }

    @Around("pet()")
    public void around(ProceedingJoinPoint joinPoint) {
        log.info("MyAspct8 around before..............");

        //获取目标对象的类名
        String name = joinPoint.getTarget().getClass().getName();
        String name1 = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        log.info("{}=={}=={}=={}", name, name1, args, signature);

        log.info("MyAspct8 around after..............");
    }
}
